package com.taotao.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.taotao.mapper.TbItemDescMapper;
import com.taotao.mapper.TbItemMapper;
import com.taotao.pojo.TbItemDesc;
import com.taotao.pojo.TbItemDescExample;
import com.taotao.pojo.TbItemDescExample.Criteria;
import com.taotao.service.ItemDescService;

/***
 * 商品管理service 实现
 * @author Administrator
 *
 */
@Service
public class ItemDescServiceImpl implements ItemDescService{
	
	//注入tapper代理对象
	@Autowired
	private TbItemMapper itemMapper;
	@Autowired
	private TbItemDescMapper itemDescMapper;
	
	/***
	 * 根据id查询TbItemDesc
	 * @param itemId
	 * @return
	 */
	@Override
	public TbItemDesc getItemDescById(long itemId) {
		
		//TbItem item = itemMapper.selectByPrimaryKey(itemId);
		
		//创建 商品管理TbItem的查询条件类TbItemExample,不添加条件是查询所有
		TbItemDescExample example = new TbItemDescExample();
		//创建查询条件
		Criteria criteria = example.createCriteria();
		//如同 where id = ? 之后把itemId作为参数
		criteria.andItemIdEqualTo(itemId);
		List<TbItemDesc> list = itemDescMapper.selectByExample(example);
		if(list != null && list.size() > 0){
			return list.get(0);
		}
		return null;
	}
	
	
}
